<template>
  <div class="container">
    <el-dropdown trigger="click" @command="handleCommand">
      <div>
        <svg-icon style="color:#fff;font-size:20px" icon-class="language" />
      </div>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="zh" :disabled="'zh'===$i18n.locale">中文</el-dropdown-item>
        <el-dropdown-item command="en" :disabled="'en'===$i18n.locale">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>
<script>
export default {
  name: 'Lang',
  methods: {
    handleCommand(command) {
      this.$i18n.locale = command
      this.$message.success(command === 'zh' ? '切换中文成功' : '切换英文成功')
    }
  }
}
</script>
<style scoped lang="less"></style>
